package org.example.curriculum_design_6_16.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.curriculum_design_6_16.entity.pojo.ScholarshipCandidate;
import org.example.curriculum_design_6_16.entity.vo.ScholarshipRankingVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import java.util.List;

/**
* @author 郑凯
* @description 针对表【scholarship_candidate】的数据库操作Mapper
* @createDate 2025-06-16 09:26:01
* @Entity org.example.curriculum_design_6_16.entity.pojo.ScholarshipCandidate
*/
@Mapper
public interface ScholarshipCandidateMapper extends BaseMapper<ScholarshipCandidate> {

    /**
     * 调用存储过程计算指定年级的奖学金排名
     * @param grade 年级：2-研二，3-研三
     * @param academicYear 学年
     * @param scholarshipType 奖学金类型
     */
    void calculateScholarshipRanking(
        @Param("grade") Integer grade,
        @Param("academicYear") String academicYear,
        @Param("scholarshipType") String scholarshipType
    );

    /**
     * 调用存储过程计算所有年级的奖学金排名
     * @param academicYear 学年
     * @param scholarshipType 奖学金类型
     */
    void calculateAllScholarshipRankings(
        @Param("academicYear") String academicYear,
        @Param("scholarshipType") String scholarshipType
    );

    /**
     * 获取指定年级的奖学金排名结果
     * @param grade 年级：2-研二，3-研三
     * @param academicYear 学年
     * @param scholarshipType 奖学金类型
     * @return 排名结果列表
     */
    List<ScholarshipRankingVo> getScholarshipRanking(
        @Param("grade") Integer grade,
        @Param("academicYear") String academicYear,
        @Param("scholarshipType") String scholarshipType
    );

    /**
     * 获取学生的奖学金排名
     * @param studentId 学生ID
     * @param academicYear 学年
     * @param scholarshipType 奖学金类型
     * @return 学生排名信息
     */
    @Select("SELECT * FROM scholarship_candidate WHERE student_id = #{studentId} AND application_year = #{academicYear} AND scholarship_type = #{scholarshipType}")
    ScholarshipCandidate getStudentRanking(
        @Param("studentId") String studentId,
        @Param("academicYear") String academicYear,
        @Param("scholarshipType") String scholarshipType
    );
}




